home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_applesingle.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  2KB  |  82 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. import unittest
  5. import macostools
  6. import Carbon.File as Carbon
  7. import MacOS
  8. import os
  9. import sys
  10. from test import test_support
  11. import struct
  12. import applesingle
  13. AS_MAGIC = 333312
  14. AS_VERSION = 131072
  15. dataforkdata = 'hello\r\x00world\n'
  16. resourceforkdata = 'goodbye\ncruel\x00world\r'
  17. applesingledata = struct.pack('ll16sh', AS_MAGIC, AS_VERSION, 'foo', 2) + struct.pack('llllll', 1, 50, len(dataforkdata), 2, 50 + len(dataforkdata), len(resourceforkdata)) + dataforkdata + resourceforkdata
  18. TESTFN2 = test_support.TESTFN + '2'
  19.  
  20. class TestApplesingle(unittest.TestCase):
  21.     
  22.     def setUp(self):
  23.         fp = open(test_support.TESTFN, 'w')
  24.         fp.write(applesingledata)
  25.         fp.close()
  26.  
  27.     
  28.     def tearDown(self):
  29.         
  30.         try:
  31.             os.unlink(test_support.TESTFN)
  32.         except:
  33.             pass
  34.  
  35.         
  36.         try:
  37.             os.unlink(TESTFN2)
  38.         except:
  39.             pass
  40.  
  41.  
  42.     
  43.     def compareData(self, isrf, data):
  44.         if isrf:
  45.             fp = MacOS.openrf(TESTFN2, '*rb')
  46.         else:
  47.             fp = open(TESTFN2, 'rb')
  48.         filedata = fp.read(1000)
  49.         self.assertEqual(data, filedata)
  50.  
  51.     
  52.     def test_applesingle(self):
  53.         
  54.         try:
  55.             os.unlink(TESTFN2)
  56.         except:
  57.             pass
  58.  
  59.         applesingle.decode(test_support.TESTFN, TESTFN2)
  60.         self.compareData(False, dataforkdata)
  61.         self.compareData(True, resourceforkdata)
  62.  
  63.     
  64.     def test_applesingle_resonly(self):
  65.         
  66.         try:
  67.             os.unlink(TESTFN2)
  68.         except:
  69.             pass
  70.  
  71.         applesingle.decode(test_support.TESTFN, TESTFN2, resonly = True)
  72.         self.compareData(False, resourceforkdata)
  73.  
  74.  
  75.  
  76. def test_main():
  77.     test_support.run_unittest(TestApplesingle)
  78.  
  79. if __name__ == '__main__':
  80.     test_main()
  81.  
  82.